#ifndef _SINE_WARP_H
#define _SINE_WARP_H


#include "stdafx.h"

class SineWarp
{
public:
	SineWarp(double amp, double phase, double period, double constant, double straight, double halfRatio, bool mod = false);
	~SineWarp();
	void SetOriginalKnotsOnTimeAxis(const std::vector<double>& knots);
	void SetCurrentKnotsOnTimeAxis(const std::vector<double>& knots);
	void SetParametersGreg(double param1, double param2, double param3);
	double EvaluateValue(double time);
	double EvaluateDerivative(double time);
	double EvaluateSine(double time);
	double EvaluateSineMod(double time);
	double EvaluateCosine(double time);
	double getBeizierValue(double fraction, const std::vector<double>& knots);
private:
	double mAmp;
	double mPhase;
	double mPeriod;
	double mConst;
	double mTotalPeriod;
	double mStraightLength;
	double mHalfRatio;
	bool mMod;
	std::vector<double> mOriKnots;
	std::vector<double> mCurKnots;
	double rectifyTimeToFractionOfPeriod(double time);
	bool SecondHalfCycle(double time);
	void setSineFunction(double amp, double phase, double period, double constant, double straight, double halfRatio, bool mod);
	double evaluateValueTimeKnots(double time);
	double evaluateValueGreg(double time);
	double evaluateValueBeizier(double time);

	double TimeWarp(double time);
	double TimeWarp2(double time);
	double TimeWarp3(double time);
	double evaluateValueEdward(double time);


	double bisectionSearch(double searchValue, double minValue, double maxValue);
	double bias(double b, double t);
	double gain(double g, double t);
};

#endif